/*******************************************************************************
 * File Name: GPS_Configuration.cpp
 *
 * Version: 1.0
 *
 * Description:
 * 	
 * Author: ppks
 *
 * Notes:
 * 	
 *
 ********************************************************************************
 * Copyright (<year>)
 ********************************************************************************
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 ********************************************************************************/

#include "common.h"
#include "GPS_common.h"
#include "EEPROM.h"

/********************************************************************************/
/* Global Variables Declaration                                                 */
/********************************************************************************/
GPSConfig_t         GPS_Config; /* Global GPS Configuration Structure */

/********************************************************************************/
/* Local Variables Declaration                                                  */
/********************************************************************************/

/********************************************************************************/
/* Local Functions Declaration                                                  */
/********************************************************************************/


/********************************************************************************/
/* Function Code                                                                */
/********************************************************************************/
/********************************************************************************
* Function Name: GPS_LoadDefaultConfiguration
*********************************************************************************
* Summary:
*
*
* Parameters:
*  None
*
* Return:
*  None
*
*********************************************************************************/
void GPS_LoadDefaultConfiguration(void)
{
    /* Clear GPS Configuration Structure */
    memset((uint8_t*)&GPS_Config, 0, sizeof(GPS_Config));

#if defined(GPS_FILTERING)
    GPS_Config.filtering = 1;
#endif /* defined(GPS_FILTERING) */
#if defined (GPS_LEAD_FILTER)
    GPS_Config.lead_filter = 1;
#endif /* defined (GPS_LEAD_FILTER) */
#if defined (DONT_RESET_HOME_AT_ARM)
    GPS_conf.dont_reset_home_at_arm = 1;
#endif /* defined (DONT_RESET_HOME_AT_ARM) */

    GPS_Config.nav_controls_heading     = NAV_CONTROLS_HEADING;
    GPS_Config.nav_tail_first           = NAV_TAIL_FIRST;
    GPS_Config.nav_rth_takeoff_heading  = NAV_SET_TAKEOFF_HEADING;
    GPS_Config.slow_nav                 = NAV_SLOW_NAV;
    GPS_Config.wait_for_rth_alt         = NAV_WAIT_FOR_RTH_ALT;
    GPS_Config.ignore_throttle          = NAV_IGNORE_THROTTLE;
    GPS_Config.takeover_baro            = NAV_TAKEOVER_BARO;
    GPS_Config.wp_radius                = GPS_WP_RADIUS;
    GPS_Config.safe_wp_distance         = SAFE_WP_DISTANCE;
    GPS_Config.nav_max_altitude         = MAX_NAV_ALTITUDE;
    GPS_Config.nav_speed_max            = NAV_SPEED_MAX;
    GPS_Config.nav_speed_min            = NAV_SPEED_MIN;
    GPS_Config.crosstrack_gain          = NAV_CROSSTRACK_GAIN * 100;
    GPS_Config.nav_bank_max             = NAV_BANK_MAX;
    GPS_Config.rth_altitude             = NAV_RTH_ALTITUDE;
    GPS_Config.fence                    = NAV_FENCE_DISTANCE;
    GPS_Config.land_speed               = LAND_SPEED;
    GPS_Config.max_wp_number            = EEPROM_GetMaxWaypointRecords();

    /* Update the configuration in EEPROM */
    EEPROM_WriteGPSConfig();
}

/********************************************************************************
* Function Name: GPS_LoadConfiguration
*********************************************************************************
* Summary:
*
*
* Parameters:
*  None
*
* Return:
*  None
*
*********************************************************************************/
void GPS_LoadConfiguration(void)
{

}

